import type { Prisma } from "@prisma/generated-client";

export const createUserOnRole = async (
  prisma: Prisma.TransactionClient,
  data: Prisma.UserOnRoleCreateInput
) => {
  return prisma.userOnRole.create({ data });
};

export const forceDeleteUserOnRoleById = async (
  prisma: Prisma.TransactionClient,
  userId: number,
  roleId: number
) => {
  return prisma.userOnRole.delete({
    where: {
      userId_roleId: {
        userId,
        roleId,
      },
    },
  });
};

export const forceDeleteUserOnRoles = async (
  prisma: Prisma.TransactionClient,
  field: "userId" | "roleId",
  ids: number[]
) => {
  return prisma.userOnRole.deleteMany({ where: { [field]: { in: ids } } });
};
